package structuralpattern.apapter;

/**
 * @author seer
 * @date 2018/2/7 14:50
 */
public class AudioPlayer implements MediaPlayer {
    MediaAdapter mediaAdapter;

    @Override
    public void play(String audioType, String fileName) {

        // 内置支持播放mp3
        if ("mp3".equalsIgnoreCase(audioType)) {
            System.out.printf("this message from %s[%s]#%s\n", Thread.currentThread().getStackTrace()[1].getClassName(), Thread.currentThread().getStackTrace()[1].getLineNumber(), Thread.currentThread().getStackTrace()[1].getMethodName());
            return;
        }

        // adapter 提供其它格式的支持
        if ("vlc".equalsIgnoreCase(audioType) ||
                "video".equalsIgnoreCase(audioType)) {
            mediaAdapter = new MediaAdapter(audioType);
            mediaAdapter.play(audioType, fileName);
            return;
        }

        System.out.println("类型错误");
    }
}
